Skip to content

grammar(ts): vendor tree-sitter-typescript fork v0.25.2; import types follow their module - #43

Merged
inth3shadows merged 3 commits into
mainfrom
grammar/ts-fork-v0.25.2
Nov 18, 2026
Merged

inth3shadows merged 3 commits into
mainfrom
grammar/ts-fork-v0.25.2

Conversation

@inth3shadows

Copy link
Copy Markdown
Owner

What

Vendors tree-sitter-typescript fork v0.25.2 (inth3shadows/tree-sitter-typescript 1e68d2a, published as tree-sitter-typescript-next 0.25.2 on crates.io and npm) in place of ed828ca. It also makes an import type, import("m").A.B, resolve through module m's exports.

The new grammar nests expressions and types as tsc does: an operator before a generic call, as / satisfies precedence, !, readonly, constructor types, and a trailing comment after a body. It also adds import_type and using_declaration. Before this, a for (using r of rs) head turned its whole function into an ERROR, so codegraph recorded no function and no calls for it.

How

  • Vendored files: both wasm files, the kernel's C (both parser.c, common/scanner.h, tsx/src/scanner.c), the patch and the hashes. marionebl 53071c9 plus docs/grammars/tree-sitter-typescript.patch regenerates byte-identical parser.c; the patch now also carries tsx/src/scanner.c and tree-sitter.json.
  • Import types: typeQualifier (src/resolution/import-resolver.ts) recognises an import type at the head of a type path and reads it as import * as ns from "m". A module outside the project links nothing. Before, the name was matched alone and reached any namesake.
  • Differential fixtures: the four gap-* fixtures (using in for heads, import attributes on re-exports) now parse, so they are ordinary fixtures.

Measured

  • Tests: __tests__/ts-import-type-reference.test.ts has 8 cases. The 5 original ones failed before the resolver change, and each later case was added from a reviewer's failing probe.
  • Suite: 11420 passed and tsc exit 0. Three timing tests failed under load average 41 and pass when rerun, on this branch and on main alike. Kernel built from the vendored C: kernel-grammar-parity 30/30.
  • ts-differential: 0 divergent files on Effect, Zod, Excalidraw, VS Code src/ and the fixtures.
  • Held-out tree accuracy: on angular packages, nest, vite packages, trpc and shadcn-ui at pinned SHAs (13,134 files tsc parses cleanly), wrong/missed nodes went from 2,374/848 on ed828ca to 63/14. 53 of the 63 are a counting convention (asserts wraps a type_predicate).
  • Edge diff vs the deployed v1.6.3-em.5 (CODEGRAPH_KERNEL=0, same 7 repos). zod and trpc are unchanged. On the others:
    • excalidraw +1: the member of readonly T[] & {…}.
    • vite +2: import-type references.
    • angular:
      • findProviders(using: any): three bogus properties became one method.
      • 4 wrong calls onto a property named import are gone.
      • x!.m() calls are now linked.
      • 58 golden .d.ts import types now reach packages/core/src instead of the language service's mock copy of @angular/core.
      • zone.js's typeof import('../zone-spec/proxy').ProxyZoneSpec now reaches the class, not its own property.
    • nest, shadcn: unresolved-reference changes only.

Review

Dual review (the /code-review skill plus a code-reviewer agent), three rounds on the import-type change; the stop rule was met after round 3. Follow-ups are in #42.

Known limits

… follow their module

Vendors inth3shadows/tree-sitter-typescript v0.25.0 (92d973d, on crates.io as
tree-sitter-typescript-next 0.25.0) in place of ed828ca: both wasm files, the
kernel's vendored C (both parser.c, common/scanner.h, tsx/src/scanner.c), the
regenerated patch (now also tsx/src/scanner.c and tree-sitter.json, so
marionebl 53071c9 + the patch regenerates byte-identical parser.c), and the
hashes in build.rs, the provenance doc and the differential baseline.

The fork nests expressions and types as tsc does (an operator before a generic
call, `as`/`satisfies` precedence, `!`, readonly and constructor types) and
adds `import_type` and `using_declaration`. The four gap fixtures (using in for
heads, import attributes on re-exports) now parse and are ordinary fixtures.

An import type, `import("m").A.B`, now resolves as a path from module m's
exports, like `import * as ns from "m"`; a module outside the project links
nothing. Read by its last name, it linked any namesake: on angular, 58
references in generated .d.ts files reached the language service's mock copy
of @angular/core instead of packages/core, and zone.js's
`typeof import('../zone-spec/proxy').ProxyZoneSpec` linked its own property.

Checks: tsc 0; suite 11142 passed (CODEGRAPH_KERNEL unset, no prebuild);
kernel built from the vendored C: kernel-grammar-parity 30/30;
ts-differential 0 divergent on effect/zod/excalidraw/vscode/fixtures.
Held-out tree accuracy (angular, nest, vite, trpc, shadcn-ui; 13,134 files):
wrong/missed nodes 2,374/848 -> 63/14. Edge diff vs v1.6.3-em.4 on 7 TS repos:
zod, trpc unchanged; the rest explained in the provenance doc.

Known limits (docs/grammars/tree-sitter-typescript.md): some import-type
layouts are read by name alone, and a one-line generated .d.ts with many
import types costs quadratic time.
v0.25.2 (1e68d2a, published as tree-sitter-typescript-next 0.25.2 on
crates.io and npm) adds one grammar fix over v0.25.0: a same-line comment
after the closing brace of a method, function or arrow expression, or static
block belongs to what holds the body, not to the body (fork colbymchenry#115). The rest is
packaging. common/scanner.h and tsx/src/scanner.c are unchanged.

Updated: both parser.c files and wasm files, the patch (marionebl 53071c9 +
patch still regenerates byte-identical parser.c), hashes in build.rs, the
provenance doc and the differential baseline.

Checks: tsc 0; kernel rebuilt, kernel-grammar-parity 30/30; ts-differential
0 divergent; suite 11420 passed, 3 timing tests failed under load average 41
(alias-chain-length, ui-highlight cost, ui-server-api busiest symbol) and pass
when rerun, on this branch and on fork main alike. Held-out tree accuracy
(angular, nest, vite, trpc, shadcn-ui; 13,134 files): 63 wrong / 14 missed /
4 error files, the same as v0.25.0. Edge diff vs the deployed v1.6.3-em.5 on
7 TS repos: identical to the v0.25.0 run (zod, trpc unchanged).
@inth3shadows
inth3shadows merged commit 110daf1 into main Nov 18, 2026
1 check passed
@inth3shadows
inth3shadows deleted the grammar/ts-fork-v0.25.2 branch November 20, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant